<?php
// 村镇
namespace app\home\controller;
use think\Db;
class Towns extends HomeBase {

	public function bencun(){
		$townsid=input('townsid');
		$zmid=input('zmid');
		$name=input('name');
		if($townsid&&$zmid){
			$towns=get_towns($townsid);
			$info['towns']=$towns;
			$info['zmidtitle']=Db::name('Zijinmanage')->where('id',$zmid)->value('title');

			$info['cmnuns']=Db::name('Member')->where('townsid',$townsid)->count();


			$info['sbtnums']=Db::name('Zijininfo')->where('cun',$towns)->where('zmid',$zmid)->field('id')->count();
			$info['sbtpries']=Db::name('Zijininfo')->where('cun',$towns)->where('zmid',$zmid)->field('price')->sum('price');
			if($name){
				$maps=array();
				$maps[]=array('name','like','%'.$name.'%');
				$maps[]=array('cun','=',$towns);
				$maps[]=array('zmid','=',$zmid);
				$info['list']=Db::name('Zijininfo')->where($maps)->field('id,name,price,fftime')->order('id DESC')->select();
			}else{
				$info['list']=Db::name('Zijininfo')->where('cun',$towns)->where('zmid',$zmid)->field('id,name,price,fftime')->order('id DESC')->select();
			}


			if($info['list']){
				foreach ($info['list'] as $key => $value) {
					$info['list'][$key]['time']=time_nianyueri($value['fftime']);
				}
			}

		}
		if($info){
			$datas['status']=1;
			$datas['info']=$info;
		}else{
			$datas['status']=0; //无补贴内容l ！
			$datas['info']='无补贴内容';
		}
		return json($datas);

	}
}